package nc.ui.cmp.receibill.ace.handler;

import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.ui.pub.beans.UIRefPane;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pubapp.uif2app.event.IAppEventHandler;
import nc.ui.pubapp.uif2app.event.card.CardHeadTailAfterEditEvent;
import nc.vo.org.FinanceOrgVO;

public class AceHeadTailAfterEditHandler implements
		IAppEventHandler<CardHeadTailAfterEditEvent> {

	@Override
	public void handleAppEvent(CardHeadTailAfterEditEvent e) {
		BillCardPanel billCardPanel = e.getBillCardPanel();

		String key = e.getKey();
		if ("vtranstypeid".equals(key)) {
			String code = (String) ((UIRefPane) billCardPanel.getHeadItem(key)
					.getComponent()).getRefValue("pk_billtypecode");
			billCardPanel.setHeadItem("vtranstypecode", code);
		} else if ("pk_org".equals(key)) {
			String pk_group = (String) ((UIRefPane) billCardPanel.getHeadItem(
					key).getComponent()).getRefValue("pk_group");
			billCardPanel.setHeadItem("pk_group", pk_group);
			IUAPQueryBS iuapQueryBs = NCLocator.getInstance().lookup(
					IUAPQueryBS.class);
			try {
				FinanceOrgVO orgVO = (FinanceOrgVO) iuapQueryBs.retrieveByPK(
						FinanceOrgVO.class, (String) e.getValue());
				billCardPanel.setHeadItem("pk_org_v", orgVO.getPk_vid());
			} catch (Exception ex) {

			}
		}
	}

}
